package com.fgsort;

import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
 
import jxl.*;
import jxl.write.*;
import jxl.write.biff.RowsExceededException;

public class ExcelWrite {

	public void ExcelWriteFile(String sExcelFile) {

		try {
			File exlFile = new File(sExcelFile);
			WritableWorkbook writableWorkbook = Workbook.createWorkbook(exlFile);

			WritableSheet writableSheet = writableWorkbook.createSheet("FG_PLC1", 0);

			//Create Cells with contents of different data types.
			//Also specify the Cell coordinates in the constructor
			
			String[] sFunctionGroupName = new String[5]; 
			
			sFunctionGroupName[0] = "GST";
			sFunctionGroupName[1] = "RB_";
			sFunctionGroupName[2] = "SAE";
			sFunctionGroupName[3] = "LM_";
			
			for (int i = 0; i < sFunctionGroupName.length; i++) {
				Label label = new Label(i, 0, sFunctionGroupName[i]);
				///add the created cells to the sheet
				writableSheet.addCell(label);
			}

			//Write and close the workbook
			writableWorkbook.write();
			writableWorkbook.close();
			
			///open the file after creation
			Desktop.getDesktop().open(new File(sExcelFile));

		} catch (IOException e) {
			e.printStackTrace();
		} catch (RowsExceededException e) {
			e.printStackTrace();
		} catch (WriteException e) {
			e.printStackTrace();
		}
 }



}
